package com.ljw.practice;

import java.awt.Image;
import java.awt.event.KeyEvent;

import javax.swing.ImageIcon;

public class MyCraft {
	private	int	x, y;
	private	int	dx, dy;
	
	private Image craft;
	
	public MyCraft(){
		ImageIcon ii = new ImageIcon("resource/img/my_00.png");
		craft = ii.getImage();
		
		x = 40;
		y = 40;
	}
	
	public void move(){
		x += dx;
		y += dy;
	}
	
	public void keyPressed(KeyEvent e){
		int keyCode = e.getKeyCode();
		
		switch(keyCode){
			case KeyEvent.VK_RIGHT : 
				dx = 1;
				break;
			case KeyEvent.VK_LEFT : 
				dx = -1;
				break;
			case KeyEvent.VK_UP : 
				dy = -1;
				break;
			case KeyEvent.VK_DOWN : 
				dy = 1;
				break;
		}
	}
	
	public void keyReleased(KeyEvent e){
		dx = 0;
		dy = 0;
	}


	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

	public Image getCraft() {
		return craft;
	}
}